#ifndef _FUZZY_10BIN_H_
#define _FUZZY_10BIN_H_

#pragma once

#include <vector>
#include <iterator>

#ifndef MIN
#define MIN(a,b)  ((a) > (b) ? (b) : (a))
#endif

#ifndef MAX
#define MAX(a,b)  ((a) < (b) ? (b) : (a))
#endif

using namespace std;


class Fuzzy10Bin
{
public:
	Fuzzy10Bin(void);
	~Fuzzy10Bin(void);

	Fuzzy10Bin(bool KeepPreviuesValues);

	vector<double> ApplyFilter(double Hue, double Saturation, double Value, int Method);

public:
	struct FuzzyRules
	{
		int Input1;
		int Input2;
		int Input3;
		int Output;
	};

	bool					_KeepPreviuesValues;
	vector<FuzzyRules>		_Fuzzy10BinRules;
	vector<double>			_Fuzzy10BinHisto;
	vector<double>			_HueActivation;
	vector<double>			_SaturationActivation;
	vector<double>			_ValueActivation;
	vector<vector<int> >	_Fuzzy10BinRulesDefinition;

protected:
	vector<double>	_HueMembershipValues;
	vector<double>	_SaturationMembershipValues;
	vector<double>	_ValueMembershipValues;

private:

	void ParamsInit();

	void FindMembershipValueForTriangles(double Input, vector<double>& Triangles, vector<double>& MembershipFunctionToSave);

	void LOM_Defazzificator(vector<FuzzyRules>& Rules, vector<double>& Input1, vector<double>& Input2, vector<double>& Input3, vector<double>& ResultTable);

	void MultiParticipate_Equal_Defazzificator(vector<FuzzyRules>& Rules, vector<double>& Input1, vector<double>& Input2, vector<double>& Input3, vector<double>& ResultTable);

	void MultiParticipate_Defazzificator(vector<FuzzyRules>& Rules, vector<double>& Input1, vector<double>& Input2, vector<double>& Input3, vector<double>& ResultTable);

};

#endif